package FlowGraph.Nodes;

import antlr.collections.AST;

import java.util.*;
import java.io.Serializable;

import util.Line;
import FlowGraph.FlowGraphNode;

//////////////////////////////////////////////////////////////////////////
//// TryBeginNode
/**

@author Ivan Jeukens
@version v 0.1 21/02/2002
*/
public class TryBeginNode extends FlowGraphNode implements Serializable {

    public TryBeginNode(AST node) {
        super(node, TRY_BEGIN, 1, 1);
        _catchList = new LinkedList();
    }
    
    ///////////////////////////////////////////////////////////////////
    ////                        public methods                     ////    
    
    public String toString() {
        return new String("try()");
    }
    
    public void addCatch(CatchBeginNode node) {
        _catchList.add(node);
    }

    public CatchBeginNode getCatch(int index) {
        return (CatchBeginNode) _catchList.get(index);
    }
    
    public int catchSize() {
        return _catchList.size();
    }
    
    public void setTryEnd(TryEndNode tryend) {
        _tryEnd = tryend;
    }
    
    public TryEndNode getTryEnd() {
        return _tryEnd;
    }
    
    public void setFinally(FinallyBeginNode fi) {
        _finally = fi;
    }
    
    public FinallyBeginNode getFinally() {
        return _finally;
    }

    public void setBegLine(Line l) {
        _begLine = l;
    }
    
    public Line getBegLine() {
        return _begLine;
    }
    
    public void setEndLine(Line l) {
        _endLine = l;
    }
    
    public Line getEndLine() {
        return _endLine;
    }
    
    ///////////////////////////////////////////////////////////////////
    ////                      private variables                    ////

    private LinkedList _catchList;
    
    private TryEndNode _tryEnd;
    private FinallyBeginNode _finally;
    private Line _begLine;
    private Line _endLine;
}
